<?php
/* @var $this EntryController */
/* @var $model Entry */


//$model = Entry::model();


$this->breadcrumbs=array(
	'Entries'=>array('index'),
	'Manage',
);




Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#entry-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");

	require_once 'Mobile_Detect.php';
	
	

			$detect = new Mobile_Detect;
			
if ($detect->isMobile() ){
?>

<body style="background-image: url( http://i59.tinypic.com/35i0i0z.png )"> </body>


<?php
$this->menu=array(
	  array('label'=>'View All Entries', 'url'=>array('index')),
 );
 } 
 
 else
 {
 
$this->menu=array(
	array('label'=>'Add New Entry', 'url'=>array('create')),
	array('label'=>'Search Items', 'url'=>array('items/admin')),
	array('label'=>'Search Container Number', 'url'=>array('container/admin')),
	);
 }

?>
<body>

<h1>View all entries</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
    
              <?php 



$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'entry-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
	//	'id',
	//	'code',
		//'client_id',
		'date',
		
		
		array(	
        'name'  => 'code',
        'value' => 'CHtml::link($data->code, Yii::app()
 ->createUrl("entry/view",array("id"=>$data->primaryKey)))',
        'type'  => 'raw',
    ),
	
	
	array(
		'header' => 'Container/s',
	 'filter'=>CHtml::listData(Container::model()->findAll(array('order'=>'code ASC')), 'id', 'code'),
		'filter' => CHtml::activeTextField(Container::model(), 'code'),
                        'value'=>function($data) { 
						
						
                            return implode(', ', array_keys($data->container(array('index' => 'code'))));
                         } 
                ), 
				
		 
		  array('name'=>'status_id', 'header'=>'Status', 'value'=>'$data->status->description'),
		
		

array('name'=>'client_id', 'header'=>'Client', 'value'=>'$data->client->name'),
//array('name'=>'port_id', 'header'=>'Port', 'value'=>'$data->port->name'),

array('name'=>'port_id', 'header'=>'Port', 'type'=>'raw',
		  'value'=>'CHtml::link($data->port->name, array("port/view", "id"=>$data->port_id))', ),
//array('name'=>'shipping_line_id', 'header'=>'Shipping Line', 'value'=>'$data->shippingLine->name'),

array('name'=>'shipping_line_id', 'header'=>'Shipping Line', 
		'type'=>'raw',
		  'value'=>'CHtml::link($data->shippingLine->name, array("shippingLine/view", "id"=>$data->shipping_line_id))', ),

		
		
	
		
		'customs_entry_no',
		'item',
		'final_assement_payment_date',
		'ETA',
		'selectivity',
		'bill_of_lading_no',
		'section',
		'container_size',
		
		
		
	
		
		/*
		array(
			'class'=>'CButtonColumn',
		),
		*/
	),
));?>


